<template>
  <div class="myComment">
    <van-nav-bar
      :border="false"
      title="我的跟帖"
      left-text="返回"
      left-arrow
      @click-left="$router.back()"
    />
    <div class="item" v-for="item in commentList" :key="item.id">
      <div class="time">2020-9-29</div>
      <!-- 父评论 -->
      <div class="parentComment" v-if="item.parent">
        <div class="username">回复:{{ item.parent.user.nickname }}</div>
        <div class="content">
          {{ item.parent.content }}
        </div>
      </div>
      <div class="replyInfo">{{ item.content }}</div>
      <div class="originalPost">原文:{{ item.post.title }}</div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      commentList: [],
    };
  },
  created() {
    this.$axios({
      url: "/user_comments",
    }).then((res) => {
      console.log(res.data.data);
      this.commentList = res.data.data;
    });
  },
};
</script>

<style lang="less" scoped>
.myComment {
  background-color: papayawhip;
  .van-nav-bar {
    background: unset;
  }
  .item {
    padding: 16/360 * 100vw;
    border-bottom: 1px solid #ccc;
    .time {
      font-size: 14px;
      color: #888;
    }
    .parentComment {
      background-color: #e4e4e4;
      padding: 10/360 * 100vw;
      font-size: 14/360 * 100vw;
      color: #888;
      .username {
        margin-bottom: 8/360 * 100vw;
      }
      .content {
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
      }
    }
    .replyInfo {
      margin: 6px 0;
    }
    .originalPost {
      font-size: 14/360 * 100vw;
      color: #888;
    }
  }
}
</style>